import java.util.Arrays;

//public class Test {
//    public static int func(int[] array){
//        Arrays.sort(array);
//        return array[array.length/2];
//    }
//    public static void main(String[] args) {
//        int[] array = {1,2,1,1,1,2,2};
//        int ret = func(array);
//        System.out.println(ret);
//    }
//}




//public class Test {
//    public static boolean func(int[] array){
//    int count = 0;
//        for (int i = 0; i < array.length; i++) {
//            if(array[i] % 2 != 0){
//                count++;
//                if(count == 3){
//                    return true;
//                }
//            }else{
//                count = 0;
//            }
//        }
//        return false;
//    }
//
//    public static void main(String[] args) {
//        int[] array = {1,2,34,3,4,5,7,23,12};
//        boolean flag = func(array);
//        System.out.println(flag);
//    }
//}




//数组翻转

//public class Test {
//    public static void reverse(int[] array){
//        int left = 0;
//        int right = array.length - 1 ;
//        while(left < right){
//            int tmp = array[left];
//            array[left] = array[right];
//            array[right] = tmp;
//            left++;
//            right--;
//        }
//    }
//    public static void main(String[] args) {
//        int[] array = {1,2,34,3,4,5,7,23,12};
//        reverse(array);
//        System.out.println(Arrays.toString(array));
//    }
//}




//public class Test {
//    public static void main(String[] args) {
//        int[][] array = {{1,2,3},{4,5,6}};
//        int[][] array2 = new int[][]{{1,2,3},{4,5,6}};
//        int[][] array3 = new int[2][3];
//    }
//}




//public class Test {
//    public static void main(String[] args) {
//        int[][] array = {{1,2,3},{4,5,6}};
//        for (int i = 0; i < 2; i++) {
//            for (int j = 0; j < 3; j++) {
//                System.out.print(array[i][j] + " ");
//            }
//            System.out.println();
//        }
//        System.out.println("==========================");
//
//        for (int i = 0; i < array.length; i++) {
//            for (int j = 0; j < array[i].length; j++) {
//                System.out.print(array[i][j] + " ");
//            }
//            System.out.println();
//        }
//        System.out.println("==========================");
//
//        System.out.println(Arrays.deepToString(array));
//        System.out.println("==========================");
//
//        System.out.println(array[0].length);
//        System.out.println(array[1].length);
//        System.out.println("==========================");
//        System.out.println(array.length);
//        System.out.println("==========================");
//        System.out.println(array[0]);
//        System.out.println(array[1]);
//        System.out.println("==========================");
//        System.out.println(Arrays.toString(array[0]));
//        System.out.println(Arrays.toString(array[1]));
//
//
//        int[][] array2 = new int[2][];
//        array2[0] = new int[]{1,2,3};
//        array2[1] = new int[]{4,5,6,7,8,9};
//        System.out.println(Arrays.deepToString(array2));
//    }
//}



//public class Test {
//    class WashMachine{
//        //成员属性/字段：是定义在类里面 方法的外面
//        public String brand;
//        public String type;
//        public double weight;
//        public double length;
//        public double width;
//        public double height;
//        public String color;
//
//        public void WashClothes(){
//            System.out.println("洗衣功能");
//        }
//        public void DryClothes(){
//            System.out.println("脱水功能");
//        }
//        public void SetTime(){
//            System.out.println("定时功能");
//        }
//    }
//}







/*//实例化一个类

class Dog{
    public String name;
    public int age;
    public String color;

    public void eat(){
        System.out.println(name + "进食");
    }

    public void barks(){
        System.out.println(name + "吠叫");
    }
}

public class Test{
    public static void main(String[] args){
        Dog petDog = new Dog();
        petDog.name = "初一";
        petDog.age = 10;
        petDog.color = "黄色";
        System.out.println(petDog.name);
        System.out.println(petDog.age);
        System.out.println(petDog.color);
        petDog.eat();
        petDog.barks();

        Dog petDog2 = new Dog();
        petDog2.name = "初二";
        petDog2.age = 12;
        petDog2.color = "黑色";
        System.out.println(petDog2.name);
        System.out.println(petDog2.age);
        System.out.println(petDog2.color);
        petDog2.eat();
        petDog2.barks();
    }
}*/







//class PetDog {
//    public String name;
//    public String color;
//    public int age;
//
//    public void bark() {
//        System.out.println(name + "汪汪叫");
//    }
//
//    public void eat() {
//        System.out.println(name +"进食");
//    }
//
//    public void wag() {
//        System.out.println(name +"摇尾巴");
//    }
//}
//
//public class Test {
//        public static void main(String[] args) {
//            PetDog dog = new PetDog();
//            dog.age = 10 ;
//            dog.name = "小黄";
//            dog.color = "黄色";
//            System.out.println(dog.age);
//            System.out.println(dog.name);
//            System.out.println(dog.color);
//            dog.eat();
//            dog.bark();
//            dog.wag();
//            System.out.println("========================");
//            PetDog dog2 = new PetDog();
//            dog2.age = 12 ;
//            dog2.name = "小黑";
//            dog2.color = "黑色";
//            System.out.println(dog2.age);
//            System.out.println(dog2.name);
//            System.out.println(dog2.color);
//            dog2.eat();
//            dog2.bark();
//            dog2.wag();
//        }
//}







//实例化一个日期类并输出值
/*
class Date{
    public int year;
    public int month;
    public int day;

    public void setDate(int y , int m ,int d){
        year = y;
        month = m;
        day = d;
    }
    public void printDate(){
        System.out.println("年:" + year + " "+ "月:" + month + " " + "日:" + day);
    }


        public static void main(String[] args) {
            Date date = new Date();
            date.setDate(2022 , 5 , 20 );
            date.printDate();
        }
    }*/








//当局部变量名与对象名冲突

class Data{
    public int year;
    public int month;
    public int day;

    public void setDay(int year,int month,int day){
        this.year = year;
        this.month = month;
        this.day = day;
    }
    public void printDay(){
        System.out.println("年："+ this.year + " " + "月：" + this.month + " " + "日：" + this.day + " ");
    }
}
public class Test {
    public static void main(String[] args) {
        Data date = new Data();
        date.setDay(2023 , 7 ,20);
        date.printDay();
        Data date2 = new Data();
        date.setDay(2021 , 1 ,21);
        date.printDay();
    }
}
